﻿
namespace ATA.Windows.Forms
{
	/// <summary>
	/// This is the abstract edit form for the <see cref="Entities.DoanhSo"/> entity.
	/// </summary>
	/// <remarks>This class is overwritten by .netTiers at each generation.</remarks>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class DoanhSoEditControlBase : System.Windows.Forms.UserControl
	{
		#region Fields
		
		//private System.Windows.Forms.TableLayoutPanel uxTableLayoutPanel;
		/// <summary>
		/// The ErrorProvider for the Entity;
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxErrorProvider;
		
		/// <summary>
		/// The BindingSource for the entity.
		///</summary>
		protected System.Windows.Forms.BindingSource uxBindingSource;
						
		
		/// <summary>
		/// TextBox for the Id property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxId;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the Id property.
		/// </summary>
		protected System.Windows.Forms.Label uxIdLabel;
		
		/// <summary>
		/// TextBox for the SoHoaDon property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxSoHoaDon;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the SoHoaDon property.
		/// </summary>
		protected System.Windows.Forms.Label uxSoHoaDonLabel;
		
		/// <summary>
		/// DataTimePicker for the NgayLayHang property.
		/// </summary>
		protected System.Windows.Forms.DateTimePicker uxNgayLayHang;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the NgayLayHang property.
		/// </summary>
		protected System.Windows.Forms.Label uxNgayLayHangLabel;
		
		/// <summary>
		/// ComboBox for the KhachHangId property.
		/// </summary>
		protected System.Windows.Forms.ComboBox uxKhachHangId;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the KhachHangId property.
		/// </summary>
		protected System.Windows.Forms.Label uxKhachHangIdLabel;
		
		/// <summary>
		/// TextBox for the InventoryItemId property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxInventoryItemId;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the InventoryItemId property.
		/// </summary>
		protected System.Windows.Forms.Label uxInventoryItemIdLabel;
		
		/// <summary>
		/// TextBox for the SoLuong property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxSoLuong;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the SoLuong property.
		/// </summary>
		protected System.Windows.Forms.Label uxSoLuongLabel;
		
		/// <summary>
		/// TextBox for the DonGia property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxDonGia;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the DonGia property.
		/// </summary>
		protected System.Windows.Forms.Label uxDonGiaLabel;
		
		/// <summary>
		/// TextBox for the ThanhTien property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxThanhTien;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the ThanhTien property.
		/// </summary>
		protected System.Windows.Forms.Label uxThanhTienLabel;
		
		/// <summary>
		/// TextBox for the GhiChu property. 
		/// </summary>
		protected System.Windows.Forms.TextBox uxGhiChu;
		
		/// <summary>
		/// The <see cref="System.Windows.Forms.Label"/> associated with the GhiChu property.
		/// </summary>
		protected System.Windows.Forms.Label uxGhiChuLabel;
		#endregion
		
		#region Main entity
		private Entities.DoanhSo _DoanhSo;
		/// <summary>
		/// Gets or sets the <see cref="Entities.DoanhSo"/> entity to edit with this form.
		/// </summary>
		/// <value>The <see cref="Entities.DoanhSo"/> instance.</value>
		public Entities.DoanhSo DoanhSo
		{
			get {return this._DoanhSo;}
			set
			{
				this._DoanhSo = value;
				if (value != null) 
				{
					this.uxBindingSource.DataSource = value;
					BindControls();
				}			
				
			}
		}
		#endregion
		
		/// <summary>
		/// Binds the controls.
		/// </summary>
		private void BindControls()
		{
			this.uxId.DataBindings.Clear();
			this.uxId.DataBindings.Add("Text", this.uxBindingSource, "Id", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxSoHoaDon.DataBindings.Clear();
			this.uxSoHoaDon.DataBindings.Add("Text", this.uxBindingSource, "SoHoaDon", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxNgayLayHang.DataBindings.Clear();
			this.uxNgayLayHang.DataBindings.Add("Value", this.uxBindingSource, "NgayLayHang", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxKhachHangId.DataBindings.Clear();
			this.uxKhachHangId.DataBindings.Add("SelectedValue", this.uxBindingSource, "KhachHangId", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxInventoryItemId.DataBindings.Clear();
			this.uxInventoryItemId.DataBindings.Add("Text", this.uxBindingSource, "InventoryItemId", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxSoLuong.DataBindings.Clear();
			this.uxSoLuong.DataBindings.Add("Text", this.uxBindingSource, "SoLuong", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxDonGia.DataBindings.Clear();
			this.uxDonGia.DataBindings.Add("Text", this.uxBindingSource, "DonGia", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxThanhTien.DataBindings.Clear();
			this.uxThanhTien.DataBindings.Add("Text", this.uxBindingSource, "ThanhTien", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
			this.uxGhiChu.DataBindings.Clear();
			this.uxGhiChu.DataBindings.Add("Text", this.uxBindingSource, "GhiChu", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
		}					
		
		#region Constructor
		
		/// <summary>
		/// Initializes a new instance of the <see cref="DoanhSoEditControlBase"/> class.
		/// </summary>
		public DoanhSoEditControlBase()
		{
			InitializeComponent();			
			
			this.uxBindingSource.CurrentItemChanged += new System.EventHandler(uxBindingSource_currentItemChanged);
		}		
		
		/// <summary>
		/// 
		/// </summary>
		private void uxBindingSource_currentItemChanged(object sender, System.EventArgs e)
		{
			if (_DoanhSo != null) _DoanhSo.Validate();
		}	
				
		/// <summary>
		/// Initializes the component.
		/// </summary>
		public void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.uxErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxBindingSource = new System.Windows.Forms.BindingSource(this.components);
			
			//this.uxTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
			this.uxId = new System.Windows.Forms.TextBox();
			uxIdLabel = new System.Windows.Forms.Label();
			this.uxSoHoaDon = new System.Windows.Forms.TextBox();
			uxSoHoaDonLabel = new System.Windows.Forms.Label();
			this.uxNgayLayHang = new System.Windows.Forms.DateTimePicker();
			uxNgayLayHangLabel = new System.Windows.Forms.Label();
			this.uxKhachHangId = new System.Windows.Forms.ComboBox();
			uxKhachHangIdLabel = new System.Windows.Forms.Label();
			this.uxInventoryItemId = new System.Windows.Forms.TextBox();
			uxInventoryItemIdLabel = new System.Windows.Forms.Label();
			this.uxSoLuong = new System.Windows.Forms.TextBox();
			uxSoLuongLabel = new System.Windows.Forms.Label();
			this.uxDonGia = new System.Windows.Forms.TextBox();
			uxDonGiaLabel = new System.Windows.Forms.Label();
			this.uxThanhTien = new System.Windows.Forms.TextBox();
			uxThanhTienLabel = new System.Windows.Forms.Label();
			this.uxGhiChu = new System.Windows.Forms.TextBox();
			uxGhiChuLabel = new System.Windows.Forms.Label();
			
			((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).BeginInit();
			this.SuspendLayout();
			
			// 
			// uxTableLayoutPanel
			// 
			//this.uxTableLayoutPanel.AutoSize = true;
			//this.uxTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
			//this.uxTableLayoutPanel.ColumnCount = 2;
			//this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 120F));
			//this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 250F));
			//this.uxTableLayoutPanel.Location = new System.Drawing.System.Drawing.Point(3, 3);
			//this.uxTableLayoutPanel.Name = "uxTableLayoutPanel";
			//this.uxTableLayoutPanel.RowCount = 2;
			//this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
			//this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
			//this.uxTableLayoutPanel.Size = new System.Drawing.Size(450, 50);
			//this.uxTableLayoutPanel.TabIndex = 0;
			
			//
			// uxErrorProvider
			//
			this.uxErrorProvider.ContainerControl = this;
			this.uxErrorProvider.DataSource = this.uxBindingSource;
			
			//
			// uxIdLabel
			//
			this.uxIdLabel.Text = "Id:";
			this.uxIdLabel.Location = new System.Drawing.Point(3, 0);
			this.Controls.Add(this.uxIdLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxIdLabel);			
			//
			// uxId
			//
			this.uxId.ReadOnly = true;
			//this.uxTableLayoutPanel.Controls.Add(this.uxId);
			this.uxId.Location = new System.Drawing.Point(160, 0);
			this.Controls.Add(this.uxId);
			//
			// uxSoHoaDonLabel
			//
			this.uxSoHoaDonLabel.Text = "SoHoaDon:";
			this.uxSoHoaDonLabel.Location = new System.Drawing.Point(3, 26);
			this.Controls.Add(this.uxSoHoaDonLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxSoHoaDonLabel);			
			//
			// uxSoHoaDon
			//
			this.uxSoHoaDon.Width = 250;
			this.uxSoHoaDon.MaxLength = 50;
			//this.uxTableLayoutPanel.Controls.Add(this.uxSoHoaDon);
			this.uxSoHoaDon.Location = new System.Drawing.Point(160, 26);
			this.Controls.Add(this.uxSoHoaDon);
			//
			// uxNgayLayHangLabel
			//
			this.uxNgayLayHangLabel.Text = "NgayLayHang:";
			this.uxNgayLayHangLabel.Location = new System.Drawing.Point(3, 52);
			this.Controls.Add(this.uxNgayLayHangLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxNgayLayHangLabel);			
			//
			// uxNgayLayHang
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxNgayLayHang);
			this.uxNgayLayHang.Location = new System.Drawing.Point(160, 52);
			this.Controls.Add(this.uxNgayLayHang);
			//
			// uxKhachHangIdLabel
			//
			this.uxKhachHangIdLabel.Text = "KhachHangId:";
			this.uxKhachHangIdLabel.Location = new System.Drawing.Point(3, 78);
			this.Controls.Add(this.uxKhachHangIdLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxKhachHangIdLabel);			
			//
			// uxKhachHangId
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxKhachHangId);
			this.uxKhachHangId.Location = new System.Drawing.Point(160, 78);
			this.Controls.Add(this.uxKhachHangId);
			//
			// uxInventoryItemIdLabel
			//
			this.uxInventoryItemIdLabel.Text = "InventoryItemId:";
			this.uxInventoryItemIdLabel.Location = new System.Drawing.Point(3, 104);
			this.Controls.Add(this.uxInventoryItemIdLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxInventoryItemIdLabel);			
			//
			// uxInventoryItemId
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxInventoryItemId);
			this.uxInventoryItemId.Location = new System.Drawing.Point(160, 104);
			this.Controls.Add(this.uxInventoryItemId);
			//
			// uxSoLuongLabel
			//
			this.uxSoLuongLabel.Text = "SoLuong:";
			this.uxSoLuongLabel.Location = new System.Drawing.Point(3, 130);
			this.Controls.Add(this.uxSoLuongLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxSoLuongLabel);			
			//
			// uxSoLuong
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxSoLuong);
			this.uxSoLuong.Location = new System.Drawing.Point(160, 130);
			this.Controls.Add(this.uxSoLuong);
			//
			// uxDonGiaLabel
			//
			this.uxDonGiaLabel.Text = "DonGia:";
			this.uxDonGiaLabel.Location = new System.Drawing.Point(3, 156);
			this.Controls.Add(this.uxDonGiaLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxDonGiaLabel);			
			//
			// uxDonGia
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxDonGia);
			this.uxDonGia.Location = new System.Drawing.Point(160, 156);
			this.Controls.Add(this.uxDonGia);
			//
			// uxThanhTienLabel
			//
			this.uxThanhTienLabel.Text = "ThanhTien:";
			this.uxThanhTienLabel.Location = new System.Drawing.Point(3, 182);
			this.Controls.Add(this.uxThanhTienLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxThanhTienLabel);			
			//
			// uxThanhTien
			//
			//this.uxTableLayoutPanel.Controls.Add(this.uxThanhTien);
			this.uxThanhTien.Location = new System.Drawing.Point(160, 182);
			this.Controls.Add(this.uxThanhTien);
			//
			// uxGhiChuLabel
			//
			this.uxGhiChuLabel.Text = "GhiChu:";
			this.uxGhiChuLabel.Location = new System.Drawing.Point(3, 208);
			this.Controls.Add(this.uxGhiChuLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxGhiChuLabel);			
			//
			// uxGhiChu
			//
			this.uxGhiChu.Width = 250;
			this.uxGhiChu.MaxLength = 16;
			//this.uxTableLayoutPanel.Controls.Add(this.uxGhiChu);
			this.uxGhiChu.Location = new System.Drawing.Point(160, 208);
			this.Controls.Add(this.uxGhiChu);
			//
			// uxKhachHangId
			//				
			this.uxKhachHangId.DisplayMember = "TenKh";	
			this.uxKhachHangId.ValueMember = "KhachHangId";	
			// 
			// DoanhSoEditControlBase
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			//this.Controls.Add(this.uxTableLayoutPanel);
			this.AutoScroll = true;
			this.Name = "DoanhSoEditControlBase";
			this.Size = new System.Drawing.Size(478, 311);
			//this.Localizable = true;
			((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).EndInit();			
			this.ResumeLayout(false);
			this.PerformLayout();
		}
		#endregion
				
		#region ComboBox List
		
				
		private Entities.TList<Entities.KhachHang> _KhachHangIdList;
		
		/// <summary>
		/// The ComboBox associated with the KhachHangId property.
		/// </summary>
		[System.ComponentModel.Category("ComboBox BindingSources")]
		public Entities.TList<Entities.KhachHang> KhachHangIdList
		{
			get {return _KhachHangIdList;}
			set 
			{
				this._KhachHangIdList = value;
				this.uxKhachHangId.DataSource = null;
				this.uxKhachHangId.DataSource = value;
			}
		}
		
		private bool _allowNewItemInKhachHangIdList;
		
		/// <summary>
		/// Indicates if the ComboBox associated with the KhachHangId property allow user to add item.
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInKhachHangIdList
		{
			get { return _allowNewItemInKhachHangIdList;}
			set
			{
				this._allowNewItemInKhachHangIdList = value;
				this.uxKhachHangId.DropDownStyle = value ? System.Windows.Forms.ComboBoxStyle.DropDown : System.Windows.Forms.ComboBoxStyle.DropDownList;
			}
		}
		
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	}
}
